package com.xucia.jsponic.datasource;

public interface WritableDataSource extends DataSource {
    /**
     * This is called when a new property is added to an object
     * @param objectId
     * @param name
     * @param value - The value should generally be an object one of the following classes: String, Boolean, Integer, Double, Date, ObjectId, or a null
     * If the value is an ObjectId than it indicates that it is a reference to another object.
     * The data source can check isPersisted to see if the object has been persisted yet. If it is true than it means
     * it means it has already been persisted. If it is false, the object has not been persisted yet. If the data
     * source can handle a new object at this point, it should call ObjectId.persist to persist the object
     * @throws Exception
     */
    void recordPropertyAddition(String objectId, String name, Object value) throws Exception;
    /**
     * This is called when a property value is changed
     * @param objectId
     * @param name
     * @param value
     * @throws Exception
     */
    void recordPropertyChange(String objectId, String name, Object value) throws Exception;
    /**
     * This is called when a property value is removed
     * @param objectId
     * @param name
     * @throws Exception
     */
    void recordPropertyRemoval(String objectId, String name) throws Exception;
    /**
     * This is called when the object is a list/array and a new value is added to it
     * @param objectId
     * @param value
     * @throws Exception
     */
    void recordListAdd(String objectId, Object value) throws Exception;
    /**
     * This is called when the object is a list/array and a value is removed from it
     * @param objectId
     * @param value
     * @throws Exception
     */
    void recordListRemoval(String objectId, Object value) throws Exception;

}
